<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <!-- <style>
      h1:nth-of-type(1),
      h1:nth-of-type(2) {
        color: red;
      }
    </style> -->
    <h1>yahoo</h1>
    <h1>tom</h1>
    <script>
      //cpu    gpu     dell
      //   document.querySelector('h1:nth-child(1)').addEventListener('click', callback)
      //   document.querySelector('h1:nth-child(2)').addEventListener('click', callback)

      let elements = document.querySelectorAll('h1:nth-child(1),h1:nth-child(2)')
      //   console.log(elements)

      elements.forEach(function (elem, i) {
        console.log(i)
      })
      //   console.log(elements)

      function callback() {
        alert(this.innerHTML)
      }
    </script>
  </body>
</html>
